from impala.dbapi import connect

def create_conn(db_name):
    return connect(host='master', port=10000,database=db_name,auth_mechanism='NOSASL')

def load_data(conn, file_url, table_name):
    cursor = conn.cursor()
    results = cursor.execute("load data local inpath '" + file_url + "' into table " + table_name)

    if results is None:
        print('在'+table_name+'加载'+file_url+'数据成功，无返回值！')


if __name__ == '__main__':
    db_name = 'default'
    table_name = 'table1'
    file_url = '/home/dataTrans/hive/a.txt'
    conn = create_conn(db_name)
    load_data(conn, file_url, table_name)